<template>
  <div>
    <p>名称<input type="text" v-model='form.name'></p>
    <p>用户名<input type="text" v-model='form.username'></p>
    <p>密码<input type="text" v-model='form.password'></p>
    <p>班级<select name="" id="" v-model='form.cla'>
    <option :value="i.id" v-for='i in clalist'>{{i.name}}</option>
  </select></p>
    <button @click='register'>提交</button>
  </div>
</template>

<script>
export default {
name: "RegStu",
  data(){
    return{
      clalist:[],
      form:{}
    }
  },
  methods: {
    getClalist(){
      this.axios.get('users/showCourse/').then(res=>{
        this.clalist = res.data.list
      })
    },
    register(){
      this.axios.post('users/reg/',this.form).then(res=>{
        if(res.data.code == 200){
          localStorage.setItem('id',res.data.id)
          localStorage.setItem('name',res.data.name)
          this.$router.push({"path":'/reg'})
        }
      })
    }
  },
  mounted() {
    this.getClalist()
  }
}
</script>

<style scoped>

</style>
